package com.hjw.exer2;

/**
 * 厨师根据餐厅传递的菜单做菜
 * @author hjwStrart
 * @create 2022-01-11 15:11
 */
public class Chef {
    private Restaurant restaurant;
    private String[] menu;

    //必须传入餐厅
    public Chef(Restaurant restaurant) {
        this.restaurant = restaurant;
    }

    public void setMenu(String[] menu) {
        this.menu = menu;
    }

    public void cooking(){
        restaurant.advice(this);
        if(menu == null){
            throw new RuntimeException("菜单为空，出错了！");
        }else{
            for (int i = 0; i < menu.length; i++) {
                System.out.println(menu[i] + "做好了！");
            }
        }
        System.out.println("客人点的菜已全部做完！");
    }
}
